package com.stock.stockana;

import android.app.Application;
import android.util.Log;

import com.stock.stockana.constants.StorageConstants;

import cn.jpush.android.api.JPushInterface;
import uk.co.chrisjenx.calligraphy.CalligraphyConfig;

/**
 * Created by ljgsonx on 2016/1/22.
 */
public class StockApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        StorageConstants.initAllFilePath(getFilesDir().getPath() + "/");
        StockCenter.init(this, StorageConstants.COMMONDB_NAME, StorageConstants.COMMONDB_VERSION);
        getMemory();
        JPushInterface.setDebugMode(true);
        JPushInterface.init(this);
        CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
                        .setDefaultFontPath("fonts/hwxs.ttf")
                        .setFontAttrId(R.attr.fontPath)
                        .build()
        );
    }

    public void getMemory() {
        //应用程序最大可用内存
        int maxMemory = ((int) Runtime.getRuntime().maxMemory())/1024/1024;
        //应用程序已获得内存
        long totalMemory = ((int) Runtime.getRuntime().totalMemory())/1024/1024;
        //应用程序已获得内存中未使用内存
        long freeMemory = ((int) Runtime.getRuntime().freeMemory())/1024/1024;
        Log.i("StockApplication--->","maxMemory=" + maxMemory + "M,totalMemory=" + totalMemory + "M,freeMemory=" + freeMemory + "M");
    }
}
